package demo.DataStrucAndAlgo.Easy_pritice;

import java.util.Collection;
import java.util.Scanner;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/9-10-09-16:03
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class Test2_360 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] chess = new int[num];
        int q = sc.nextInt();
        int lastStart = num;
        int lastEnd = 0;
        for (int i = 0; i < q; i++) {

            int start = sc.nextInt();
            int k = start;
            if(start > lastStart){
                k = lastStart;
            }
            int end = sc.nextInt();
            int k1 = end;
            if(end < lastEnd){
                k1 = lastEnd;
            }
            int count = num - (k1-k)-1;
            for (int j = k-1; j < k1; j++) {
                if(chess[j] == 1 && j < end && j >= start-1){
                    chess[j] = 0;
                    count++;
                }else if(chess[j] == 0 && j < end && j >= start-1){
                    chess[j]  = 1;
                }else if((j < start-1 || j >= end) && chess[j] == 0){
                    count++;
                }
            }
            System.out.println(count);
            lastStart = start;
            lastEnd = end;
        }
    }
}
